<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="com.ejoysoft.wlanyz.business.Comunity,com.ejoysoft.common.Constants,com.ejoysoft.util.ParamUtil"%>
<%@ include file="../include/jsp/head.jsp"%>
<%
try{
    Comunity obj=new Comunity(globa,true);
    String strUrl="comunity_list.jsp";
    String strCommId=ParamUtil.getString(request,"strCommId","");
   
    if(action.equals(Constants.DELETE_STR)){
    	//System.out.println(action+"aaaaaaaaa");
    	String[] aryStrCommId = ParamUtil.getStrArray(request, "strCommId");
    	
    	for (int i = 0; i < aryStrCommId.length; i++) {
	    	obj.delete("where strCommId ='"+aryStrCommId[i]+"'",strCommId);
	    	//System.out.println("strCommId:"+strCommId+"aaaaaaaaa");
    	}
    	globa.dispatch(true, strUrl);
	} else {
	    if(action.equals(Constants.ADD_STR)) {
			String strCity=ParamUtil.getString(request,"strCity","");
		    String strTown=ParamUtil.getString(request,"strTown","");
	    	String strSiteName=ParamUtil.getString(request,"strSiteName","");
	  
             if(obj.getCount(" where strCity='" + strCity.replaceAll(" ","") + "' and strTown='" + strTown.replaceAll(" ","") + "' and strSiteName='" + strSiteName.replaceAll(" ","") + "'")>0){
                globa.closeCon();
                out.print("<script>alert('已经存在小区:"+strSiteName.replaceAll(" ","")+", 请输入其他小区');window.location.href = 'comunity_add.jsp';</script>");
                
             }else{
          
            globa.dispatch(obj.add(strCommId),strUrl);
             }	    
		}
		else if(action.equals(Constants.UPDATE_STR)){
            //String  strMac_Addr=ParamUtil.getString(request,"strMac_Addr","");
   
             if(strUrl.indexOf(".jsp")>=0)
                 strUrl=strUrl+"?strCommId="+strCommId;
                 
                 globa.dispatch(obj.update(strCommId),strUrl);
                 //System.out.println(strUrl+"aaaaaaaaa222222222222222");
      }
     System.out.println(action+"aaaaaaaaa=============");
	}
    //关闭数据库连接对象
    globa.closeCon();
    }catch(Exception e){e.printStackTrace();}
%>